﻿using System;
using System.Collections;
using System.Collections.Generic;
using UBlockly.Graphic;
using UnityEngine;

namespace UBlockly.Util
{
    [Serializable]
    internal class BlockSoundData
    {
        [DisplayOnly]
        public string Key;
        public AudioClip Clip;

        public BlockSoundData(string key, AudioClip clip)
        {
            Key = key;
            Clip = clip;
        }
    }

    [CreateAssetMenu(fileName = "BlockSound", menuName = "Custom Assets/BlockSound Asset", order = 2)]
    public class BlockSoundAsset : ScriptableObject
    {
        [SerializeField] private List<BlockSoundData> soundDataList = new List<BlockSoundData>();

        public BlockSoundAsset()
        {
            var clip = Enum.GetNames(typeof(SoundDefine));
            foreach (var cc in clip)
            {
                soundDataList.Add(new BlockSoundData(cc,null));
            }
        }
        public AudioClip GetClip(string key)
        {
            var result = soundDataList.Find(x => x.Key == key);
            if (result != null)
                return result.Clip;
            return null;
        }
    }
}

